﻿/**
*@description 密码重置表单
*/
Chenxin.UI.ResetPwdForm=Chenxin.extend(Chenxin.UI.FormCommon,{	
	actionUrl:'service/OrganizationMgr.ashx',
	id:'changePwdWin',
	renderTo:'jqm_changepwd',
	jqmWidth:420,
	createForm:function(){
		return Chenxin.FormCommon.resetPwdForm(this.id);
	},
	initFormValidator:function(){
		var _this=this;
		var filter='#'+this.id;
		$(filter+'old_usercode').formValidator({
			validatorgroup:this.id,
            onshow: "请输入用户名!", 
			onfocus: "请输入用户名!", 
			oncorrect: " "
        }).inputValidator({ //非空验证
            min: 1, 
			empty: { 
				leftempty: false, 
				rightempty: false, 
				emptyerror: "用户名不能为空!" 
			}, 
			onerror: "用户名不能为空!"
        }).functionValidator({
            fun: function(val, elem) {
                var exist = true;
				Chenxin.ajax({
					type: "get",
					dataType: "json",
					async: false,
					url: _this.actionUrl,
					data: { op: 'getuserbycode', usercode: val},
					onSuccess: function(data) {
						if(data.userinfo){
							_this.findByName('UserName').val(data.userinfo);
							_this.currentUserId=data.UserId;
						}
						exist=data.exist;
					}
				});
				if (!exist) {
					return '用户名不存在';
				} else {
					return true;
				}
            },
            onerror: '用户名不存在！'
        });
		
		$(filter+'newpwd').formValidator({
			validatorgroup:this.id,
            onshow: "请输入新密码!", 
			onfocus: "请输入新密码!", 
			oncorrect: " "
        }).inputValidator({ //非空验证
            min: 1, 
			empty: { 
				leftempty: false, 
				rightempty: false, 
				emptyerror: "新密码不能为空!" 
			}, 
			onerror: "新密码不能为空!"
        });
	},
	initEvent:function(){	
		var _this=this;
		var filter='#'+this.id;
		$(filter+'_Save').live('click',function(){			
			_this.save();
		});
		$(filter+'_Cancle').live('click',function(){
			_this.hide();			
		});	
	},
	initComponent:function(){
		Chenxin.UI.ResetPwdForm.superclass.initComponent.call(this);
	}
});


Chenxin.FormCommon.resetPwdForm=function(comboIdPrefix){
	return '<table class="tbl_f"><tr><th style="width:80px;">工号：</th><td><input id="'+comboIdPrefix+'old_usercode" name="UserCode" class="inputbox_n fl" type="text"  style="width:160px;" /><div id="'+comboIdPrefix+'old_usercodeTip" style="float: left; margin-left: 5px; width: 90; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr id="'+comboIdPrefix+'_tr_username"><th></th><td><input name="UserName" class="inputbox_n fl" style="width:160px;" readonly="readonly"  /></td></tr><tr><th>新密码：</th><td><input id="'+comboIdPrefix+'newpwd" name="newpwd" class="inputbox_n fl" type="text"  style="width:160px;" /><div id="newpwdTip" style="float: left; margin-left: 5px; width: 90; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr><td colspan="2" align="right"><div style="float:right; margin-right:15px;"><a id="' + comboIdPrefix + '_Save" class="btn_n fl" href="#"><span>确定</span></a><a id="' + comboIdPrefix + '_Cancle"  class="btn_n fl" href="#"><span>取消</span></a></div></td></tr></table>';
};